Hello,
I have a field in a database table that stores the date at mm/dd/yy (form 101). I need to be able to delete any records in that table that are older than 6 months old. Does anyone have a suggestion on how to do this?
Thanks,
I imagine that "yourdate" would have to be in the same format as the date that is returned by the getdate() function. What format does getdate() return the date in?
Date are not stored in a format or style. They are stored as numbers - so many days before or since Jan 1, 1900. Time is stored as milliseconds since midnight. SQL Server handles datetime to character comparison implicitly if the character format is non-ambiguous - yyyy-mm-dd, mmm dd yyyy, etc.. mm/dd/yyyy is also usable because SQL accepts the American default format.
Check out my article on Handling Dates in SQL Server.
if you are not sire of the yourdate format you can test it with the isdate function, also atention to the fact 1/10/2002 is not a date on T-SQL the correct format would be 01/10/2002. AL Almeida
NT/DB Admin
"May all those that come behind us, find us faithfull"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.