Home » excel » Convert Date String In Excel to SQL datetime

Convert Date String In Excel to SQL datetime

Posted by: admin May 14, 2020 Leave a comment


I have searched for an answer to this, but have only ever found people wanting to do the reverse.

We have a reporting tool called JetReports, which is an Excel addin.

I am querying a database containing information about who has entered/left our building, and want to filter by date/time.

The filters in JetReports are literal, so if I filter the EventTime using a value of 20/09/2013 13:27, it searches for exactly that. The SQL database in question is storing this as a DATETIME value, which when converted is in fact 41172.5604167

I don’t think my users will like having convert their dates to this format before running the report, so I would like to do it for them within Excel.

Is there some way I could convert a date in the format of dd/mm/yyyy hh:mm to the SQL DATETIME format?

How to&Answers:

It does not say in your question if you are using SQL Server or not. If so, did you try to use CONVERT on the server side?

DECLARE @d nvarchar(100)
SET @d = N'30/10/2013 20:40'

SELECT CONVERT(smalldatetime, @d, 103) AS [DateTime]


The date serial numbers in excel are exactly the same, it should just be a matter of formatting, e.g. if you have 20/09/2013 13:27 and simply re-format as number with 7 decimal places then you should see 41172.5604167 as required

If the re-formatting doesn’t change the value then your date/time is text formatted. Try converting to numeric by using

Data > Text to columns > Finish