Is there a function to compare date with time, i have month(),year().etc what about a specific date? like xx()<=02/2/2006
Printable View
Is there a function to compare date with time, i have month(),year().etc what about a specific date? like xx()<=02/2/2006
You can use DateDiff to compare Dates, or Dateadd to add hours, days, months..etc
DateDiff Example: Find the diff in days between 2 dates..
Code:Dim Ld As Date
Ld = #12/8/2005#
MsgBox DateDiff("d", Ld, Date) ' "d" = Days
but if i want to compare specific month WITH year i put d (as day) is ok?
Would you elaborate? Compare date with time?
I don't understand :( , write some code so I can see what you're trying to do.Quote:
Originally Posted by Goh
You can use.. Day(Date), for days.
Also, Format(Date, "mmyy") will show you month and year (without days)
There are several date/time functions.
DateDiff
DateAdd
Hour
Minute
Second
'...
Threads merged. :)
sorry guys ...actually i only wanted to compare a certain date...as in only the
like any date that is greater or equals than 01/01/2005 ..something like that
by the way am using sql statement ... passing query in vb..
dim DateRef as date
DateRef="01/01/2005"
.
.
sql = sql & "and DateDiff("d", DateFromRecordset, DateRefer)<0 ..."
but how am i going to amend the code 'd' ?is the above correct?
then you can use the datediff functions, but why dont you post the code here, so that, we can help you properly without wasting too many posts
i want to retrieve records which dated 01/02/2005 and later..:)...the database uses smalldatetime like 16/12/1999 6:21:00 PM..
i think should use "y" ya? cause i only want month and year after the one above..
The actual problem is that if i use Year() and month() separately, things will not go right.