Link to home
Create AccountLog in
Avatar of amillyard
amillyardFlag for United Kingdom of Great Britain and Northern Ireland

asked on

compare date time

the   (an.CallBackDate <= @SystemDate+1)  is not working for me -- I suspect it has to do with these two datetime variables are formatted differently.

how do I  get to work please?

CallBackDate  -- format:  {0:dd-MMM-yy}
SystemDate -- format:  "ddd, MMM dd, yyyy"
(an.CallBackDate <= @SystemDate+1)

Open in new window

Avatar of HuyBD
Flag of Viet Nam image

try use SQL function
DATEDIFF(day,an.CallBackDate,@SystemDate) <= 1

Open in new window

Avatar of amillyard


it didn't seem to make an difference.  

I am wanting to display all records dated today and historic (not tomorrow onwards)
What's type of CallBackDate, varchar or datetime?
You can compare them if they are in the same type.

pls try to pass the date without ddd.
"MMM dd, yyyy"
CallBackDate is formatted :  {0:dd-MMM-yy}
SystemDate is formatted :   "ddd, MMM dd, yyyy"
how is this achieved?  
passing the date without ddd.
"MMM dd, yyyy"
Avatar of gnoon
Flag of Thailand image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
gnoon: yes, I think that did it !
gnoon:  many thanks :-))