Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default convert date to string of numbers

How would I write a line of code to change the date, such as 02/09/07, to a
string of numbers '020907'

I'm trying to write a line that will "save as" an excel file with a
specific name concatenated with the date at the end. Note: the date will
always change depending on the date the file is saved.

Here's a sample of the line of code I am working with

ActiveWorkbook.SaveAs Filename:= _
' "C:\Temp\SaveAsTest_" & <INSERT DATE CODE HERE & ".xls",
FileFormat _
' :=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:= _
' False, CreateBackup:=False


ds


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default convert date to string of numbers

One way:

Format(Date, "mmddyy")

In article ,
"D.S." wrote:

How would I write a line of code to change the date, such as 02/09/07, to a
string of numbers '020907'

I'm trying to write a line that will "save as" an excel file with a
specific name concatenated with the date at the end. Note: the date will
always change depending on the date the file is saved.

Here's a sample of the line of code I am working with

ActiveWorkbook.SaveAs Filename:= _
' "C:\Temp\SaveAsTest_" & <INSERT DATE CODE HERE & ".xls",
FileFormat _
' :=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:= _
' False, CreateBackup:=False


ds

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default convert date to string of numbers

I suggest writing the date backwards, helps sorting

ActiveWorkbook.SaveAs Filename:= _
' "C:\Temp\SaveAsTest_" & Format(date,"yy,mmdd") & ".xls",
FileFormat _
' :=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:= _
' False, CreateBackup:=False



--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"D.S." wrote in message
...
How would I write a line of code to change the date, such as 02/09/07, to
a string of numbers '020907'

I'm trying to write a line that will "save as" an excel file with a
specific name concatenated with the date at the end. Note: the date will
always change depending on the date the file is saved.

Here's a sample of the line of code I am working with

ActiveWorkbook.SaveAs Filename:= _
' "C:\Temp\SaveAsTest_" & <INSERT DATE CODE HERE & ".xls",
FileFormat _
' :=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:= _
' False, CreateBackup:=False


ds




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default convert date to string of numbers

Thanks. While both suggestions will work, < Format(Date,"mmddyy") will work
better for my situation. I'm using a variable for the Date because it's not
actually the current date, rather it's always a date in the past.

ds

"JE McGimpsey" wrote in message
...
One way:

Format(Date, "mmddyy")

In article ,
"D.S." wrote:

How would I write a line of code to change the date, such as 02/09/07, to
a
string of numbers '020907'

I'm trying to write a line that will "save as" an excel file with a
specific name concatenated with the date at the end. Note: the date will
always change depending on the date the file is saved.

Here's a sample of the line of code I am working with

ActiveWorkbook.SaveAs Filename:= _
' "C:\Temp\SaveAsTest_" & <INSERT DATE CODE HERE & ".xls",
FileFormat _
' :=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:= _
' False, CreateBackup:=False


ds



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
String Fractions Convert to Numbers VBA jlclyde Excel Discussion (Misc queries) 4 January 19th 09 07:46 PM
Convert numbers to text string GARY Excel Discussion (Misc queries) 3 May 22nd 08 05:05 AM
Auto convert an alphanumeric string (CIS9638S) to numbers only? Gary L Brown Excel Worksheet Functions 1 September 7th 05 01:17 AM
Can i convert numbers into string format? talia_k Excel Discussion (Misc queries) 3 April 28th 05 03:27 PM
Convert String of 512 numbers to a range Kevin G[_2_] Excel Programming 10 February 2nd 04 06:02 AM


All times are GMT +1. The time now is 02:09 AM.

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

About Us

"It's about Microsoft Excel"