Date format changes from 'yyyy-mm-dd hh:mm:ss' to 'mm/dd/yyyy'

S

ssingh

I am working on a QTP script which executes sybase queries and exports the
results to an excel. The recordset sometimes has date values, numbers with
leading zeroes etc.

To ensure that the format of all the values is retained after results are
exported to excel , I used the following code:-

ExcelObj.selection.NumberFormat = "@" to change the format of the excel to
'text'.

Inspite of using the above code the date format is getting changed :-

Sybase query originally returns date in format : 'yyyy-mm-dd hh:mm: ss' .
When this value is pasted on excel it gets changed to 'mm/dd/yyyy'.

Need help to fix this! Any suggestions?

TIA
 
T

Tom Ogilvy

Assume the date comes into column 3, then:
columns(3).Numberformat = "yyyy-mm-dd hh:mm:ss"

If it doesn't work doing it before, then do it after the data is imported
and interpreted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top