Getdate() returning date with time part trimmed off

I have few tables with various datetime columns in a SQL Server 2008 database. These tables are updated (inserted/updated/deleted) through stored procedures. So for datetime columns, insert or update happening with current timestamp returned from getdate() function. But for few of the cases, the timestamp getting saved something like "2013-09-23 00:00:00.000". For some reason, the time part is completely missing in the current timestamp returned by GEtDATE function but not always for all inserts or updates. Did anybody face any such issue before with SQL Server 2008 DB? If YES then what was the root cause of this issue and what was the fix?
LVL 12
sachitjainAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Haven't seen this before.

<Potentially stupid answers>
Make sure the column data type is datetime and not date.
See if there are any triggers in these tables that may be altering this column.
0
PortletPaulfreelancerCommented:
Maybe some coded logic that is stripping time from getdate() ?
something like this:

dateadd(day, datediff(day,0, getdate() ), 0)

in the code - somewhere:

trouble is there are several ways to perform this, and so locating it may not be so easy.
0
sachitjainAuthor Commented:
@jimhorn, as I mentioned in the question, column types are datetime only and most of the record values still have exact complete timestamp including time part. Issue is with rest of the records.

@PortletPaul, there is no such logic, it's simple call to getdate() function
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

PortletPaulfreelancerCommented:
have there been recent changes? (to code)
is there any 'pattern' to the missing time? (e.g. was it 'last week')
can that pattern be linked to code change?

getdate() somehow returning just the date would be very long odds

did someone run an update on the data?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sachitjainAuthor Commented:
have there been recent changes? (to code)
<<Sachit>> No recent changes

is there any 'pattern' to the missing time? (e.g. was it 'last week')
<<Sachit>> I have not noticed any pattern

can that pattern be linked to code change?
<<Sachit>> N/A

getdate() somehow returning just the date would be very long odds

did someone run an update on the data?
<<Sachit>> Nobody ran any update script
0
PortletPaulfreelancerCommented:
Thanks, I am out of ideas then.

best of luck hunting this down.
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Makes you wonder if it's worth firing up SQL Profiler and doing a trace on one of these tables where it's happening, to see if we can identify specific process(es) that are inserting or updating only the date component.
0
sachitjainAuthor Commented:
@PortletPaul, thanks a lot for all your help

@jimhorn, I will try this out
0
sachitjainAuthor Commented:
I still need to do more analysis around this issue but closing this question for now
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.