Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problems with date format when reading external excel sheet

When I read a coloumn "Periode end" and store it in a different sheet
I have the problem that month and day is swapped if they are both <
13.

i.e if "Periode end" is 09-03-2009 in the below - 03-09-2009 will be
stored in the target cell

How to set the read date format?

Set rs_SOURCE = New ADODB.Recordset
rs_SOURCE.Open "Select [Alert], [Period end] From
[VTM,_monitorInstances_export$] where [Unit ID] =" & Right(ms_TEMP,
5), ExcelConn, _
adOpenDynamic, adLockOptimistic

'Update Date
.Cells(ml_TARGET_ROW, 10).Value = Format
(rs_SOURCE("Period end"), "dd-mm-yyyy")
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Problems with date format when reading external excel sheet

Hi There

You could try using cdate rather than formatting the date i.e.

..cells(ml_TARGET_ROW, 10).Value = CDate (rs_SOURCE("Period end"))
'where the data in the parenthesis is your date

Hope this helps

Steve

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula not reading date format ziak Excel Discussion (Misc queries) 3 May 20th 10 09:41 PM
Copnvert dates reading as Text to a date format Margy Excel Discussion (Misc queries) 5 February 9th 09 06:53 PM
Reading from CSV date format Grd Excel Programming 2 May 25th 07 03:04 AM
Date format problems ... budgie Excel Discussion (Misc queries) 6 February 20th 06 12:33 PM
Date Format Problems?? nastech Excel Discussion (Misc queries) 5 November 14th 05 01:53 AM


All times are GMT +1. The time now is 12:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"