Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date and Time Comparison in SQL and MS Access 1

Status
Not open for further replies.

rache1

Programmer
Mar 20, 2001
9
TW
Hi.

I was wondering if there is any function equivalent to DateSerial() in MS Access in SQL 7.
Pls help!

I need to code a general query to compare dates in Visual Basic Application that makes uses of ADODB Connection for both MS Access and SQL, is there any way I could do that?

Thanks for your help! |-0


 
i'm not familiar with the DateSerial function in Access - can you briefly describe what it does?
 
The DateSerial basically 'converts' the parametes into a date, and since I have the day, month and year in separated fields, I used this function to convert the fields into a date for comparision.
e.g
Select * from mytable
Where DateSerial(dy, mth, yr) <= '19/03/2001'.

But this only works in MSAccess.

 
ah, ok. i don't believe there's an identical function in sql but this works even though its a little sloppy:

Select *
From mytable
Where
(CAST(CONVERT(varchar, dy) + '/' + CONVERT(varchar, mth) + '/' + CONVERT(varchar, yr) AS datetime)<= '19/03/2001'

i wouldn't be insulted if you held out for a better answer though (-:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top