ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   URGENT - Need date format for SaveAs code (https://www.excelbanter.com/excel-programming/281702-urgent-need-date-format-saveas-code.html)

Ed[_9_]

URGENT - Need date format for SaveAs code
 
In my VBA module, I need to save an Excel file into a folder created by a VB
program. The VB date format code is:
dates = Day(Now) & " " & Left(MonthName(Month(Now)), 3) & " " & Year(Now)
which today gave me a folder as "Folder 6 Nov 2003".

The problem is the single digit for the day, which will become a
double-digit next week. My VBA code of:
Format(Now, "dd mmm yyyy")
wants to always give me a two-digit day - and then, of course, it can't find
the folder. How can I format this to give only a single digit on
single-digit days?

Thanks.
Ed



Chip Pearson

URGENT - Need date format for SaveAs code
 
Ed,

Try

Format(Now,"d mmm yyyy")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ed" wrote in message
...
In my VBA module, I need to save an Excel file into a folder created by a

VB
program. The VB date format code is:
dates = Day(Now) & " " & Left(MonthName(Month(Now)), 3) & " " & Year(Now)
which today gave me a folder as "Folder 6 Nov 2003".

The problem is the single digit for the day, which will become a
double-digit next week. My VBA code of:
Format(Now, "dd mmm yyyy")
wants to always give me a two-digit day - and then, of course, it can't

find
the folder. How can I format this to give only a single digit on
single-digit days?

Thanks.
Ed





Jason Callas

URGENT - Need date format for SaveAs code
 
Since my preference is to always use 2 digits, my solution goes that way...

Right after dates = Day(Now) & " " & Left(MonthName(Month(Now)), 3) & " " & Year(Now) put

If Day(Now) < 10 Then dates = "0" & dates

I think it is always cleaner to use the 2 digits when dealing with month and day. When doing directory listings, the filenames line up correctly which makes reading it easier.

- Jason

"Ed" wrote in message ...
In my VBA module, I need to save an Excel file into a folder created by a VB
program. The VB date format code is:
dates = Day(Now) & " " & Left(MonthName(Month(Now)), 3) & " " & Year(Now)
which today gave me a folder as "Folder 6 Nov 2003".

The problem is the single digit for the day, which will become a
double-digit next week. My VBA code of:
Format(Now, "dd mmm yyyy")
wants to always give me a two-digit day - and then, of course, it can't find
the folder. How can I format this to give only a single digit on
single-digit days?

Thanks.
Ed



Ed[_9_]

URGENT - Need date format for SaveAs code
 
Thank you, Chip. I scrabbled through the Help files before posting, but
apparently couldn't form the proper question to find this. It works great!

Ed

"Chip Pearson" wrote in message
...
Ed,

Try

Format(Now,"d mmm yyyy")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ed" wrote in message
...
In my VBA module, I need to save an Excel file into a folder created by

a
VB
program. The VB date format code is:
dates = Day(Now) & " " & Left(MonthName(Month(Now)), 3) & " " &

Year(Now)
which today gave me a folder as "Folder 6 Nov 2003".

The problem is the single digit for the day, which will become a
double-digit next week. My VBA code of:
Format(Now, "dd mmm yyyy")
wants to always give me a two-digit day - and then, of course, it can't

find
the folder. How can I format this to give only a single digit on
single-digit days?

Thanks.
Ed







Ed[_9_]

URGENT - Need date format for SaveAs code
 
Thanks for responding, Jason. Since I like the 2-digit date also, I'll give
this a try. I'm eventually going to learn some VB, too - but right now Im
having trouble enough getting my macros right! 8)

Ed

"Jason Callas" wrote in message
...
Since my preference is to always use 2 digits, my solution goes that way...

Right after dates = Day(Now) & " " & Left(MonthName(Month(Now)), 3) & " " &
Year(Now) put

If Day(Now) < 10 Then dates = "0" & dates

I think it is always cleaner to use the 2 digits when dealing with month and
day. When doing directory listings, the filenames line up correctly which
makes reading it easier.

- Jason

"Ed" wrote in message
...
In my VBA module, I need to save an Excel file into a folder created by a

VB
program. The VB date format code is:
dates = Day(Now) & " " & Left(MonthName(Month(Now)), 3) & " " & Year(Now)
which today gave me a folder as "Folder 6 Nov 2003".

The problem is the single digit for the day, which will become a
double-digit next week. My VBA code of:
Format(Now, "dd mmm yyyy")
wants to always give me a two-digit day - and then, of course, it can't

find
the folder. How can I format this to give only a single digit on
single-digit days?

Thanks.
Ed






All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com