?
Solved

date format

Posted on 2003-11-25
7
Medium Priority
?
795 Views
Last Modified: 2011-10-03
How do I change Month(Date) from giving me the number to the 3 letter equivalent?
0
Comment
Question by:craigs052998
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 9818205
Hi craigs,

Use Format(MyDateValue,"mmm")

Instead.

Tim Cottee MCSD, MCDBA, CPIM
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 

Author Comment

by:craigs052998
ID: 9818270

How would I change that in my code?

sDestinationFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory_" & Day(Date) & "_" & Month(Date) & "_" & Year(Date) &".mdc"

Like this????
sDestinationFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory_" & Day(Date) & "_" & Format(Date,"mmm") & "_" & Year(Date) &".mdc"


0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9818296
Exactly.

AW
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9818307
in fact, you can do it all at once:

sDestinationFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory_" & Format(Date,"dd_mmm_yyyy") & ".mdc"

AW
0
 

Author Comment

by:craigs052998
ID: 9818402

I get an error on line 18 char 1 TypeMissmatch:'Format'

Oh and this is also done as a vbs file if that matters



Dim oFSO
Dim sSourceFile_1
Dim sSourceFile_2
Dim sSourceFile_3
Dim sSourceFile_4
Dim sDestinationFile_1
Dim sDestinationFile_2
Dim sDestinationFile_3
Dim sDestinationFile_4
Dim MvLoc
Dim SysDate
Dim FSys


Set oFSO = CreateObject("Scripting.FileSystemObject")

sSourceFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory.mdc"
sDestinationFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory_" & Format(Date,"dd_mmm_yyyy") & ".mdc"

sSourceFile_2 = "C:\PowerPlay\CubesToPublish\c002_reo_ie_post_foreclosure.mdc"
sDestinationFile_2 = "C:\PowerPlay\CubesToPublish\c002_reo_ie_post_foreclosure_" & Format(Date,"dd_mmm_yyyy") & ".mdc"

sSourceFile_3 = "C:\PowerPlay\CubesToPublish\c003_reo_sales_performance.mdc"
sDestinationFile_3 = "C:\PowerPlay\CubesToPublish\c003_reo_sales_performance_" & Format(Date,"dd_mmm_yyyy") & ".mdc"

sSourceFile_4 = "C:\PowerPlay\CubesToPublish\C004_reo_ie_eviction_tracking.mdc"
sDestinationFile_4 = "C:\PowerPlay\CubesToPublish\C004_reo_ie_eviction_tracking_" & Format(Date,"dd_mmm_yyyy") & ".mdc"

MvLoc = "\\namcfmsolfs012\ftpshare\REOArchive\"

oFSO.CopyFile sSourceFile_1,sDestinationFile_1
oFSO.CopyFile sSourceFile_2,sDestinationFile_2
oFSO.CopyFile sSourceFile_3,sDestinationFile_3
oFSO.CopyFile sSourceFile_4,sDestinationFile_4

oFSO.MoveFile sDestinationFile_1,MvLoc
oFSO.MoveFile sDestinationFile_2,MvLoc
oFSO.MoveFile sDestinationFile_3,MvLoc
oFSO.MoveFile sDestinationFile_4,MvLoc








0
 
LVL 43

Accepted Solution

by:
TimCottee earned 400 total points
ID: 9818489
And there is the problem, VBScript doesn't support the Format() function. You do have the FormatDateTime option though this doesn't allow you to specify the format in the same way.

If your system's long date format in regional settings is dd/mmm/yyyy you could use replace to change the / to _ or you have to handle it in a function call:

Dim oFSO
Dim sSourceFile_1
Dim sSourceFile_2
Dim sSourceFile_3
Dim sSourceFile_4
Dim sDestinationFile_1
Dim sDestinationFile_2
Dim sDestinationFile_3
Dim sDestinationFile_4
Dim MvLoc
Dim SysDate
Dim FSys


Set oFSO = CreateObject("Scripting.FileSystemObject")

sSourceFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory.mdc"
sDestinationFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory_" & GetTheDate() & ".mdc"

sSourceFile_2 = "C:\PowerPlay\CubesToPublish\c002_reo_ie_post_foreclosure.mdc"
sDestinationFile_2 = "C:\PowerPlay\CubesToPublish\c002_reo_ie_post_foreclosure_" & GetTheDate() & ".mdc"

sSourceFile_3 = "C:\PowerPlay\CubesToPublish\c003_reo_sales_performance.mdc"
sDestinationFile_3 = "C:\PowerPlay\CubesToPublish\c003_reo_sales_performance_" & GetTheDate() & ".mdc"

sSourceFile_4 = "C:\PowerPlay\CubesToPublish\C004_reo_ie_eviction_tracking.mdc"
sDestinationFile_4 = "C:\PowerPlay\CubesToPublish\C004_reo_ie_eviction_tracking_" & GetTheDate() & ".mdc"

MvLoc = "\\namcfmsolfs012\ftpshare\REOArchive\"

oFSO.CopyFile sSourceFile_1,sDestinationFile_1
oFSO.CopyFile sSourceFile_2,sDestinationFile_2
oFSO.CopyFile sSourceFile_3,sDestinationFile_3
oFSO.CopyFile sSourceFile_4,sDestinationFile_4

oFSO.MoveFile sDestinationFile_1,MvLoc
oFSO.MoveFile sDestinationFile_2,MvLoc
oFSO.MoveFile sDestinationFile_3,MvLoc
oFSO.MoveFile sDestinationFile_4,MvLoc

Function GetTheDate()
  Dim intDay
  Dim strMonth
  Dim intMonth
  Dim intYear
  intDay = Day(Date)
  intYear = Year(Date)
  intMonth = Month(Date)
  Select Case intMonth
  Case 1
    strMonth = "Jan"
  Case 2
    strMonth = "Feb"
 ....
  End Select
  GetTheDate = CStr(intDay) & "_" & strMonth & "_" & CStr(intYear)
End Function
0
 

Author Comment

by:craigs052998
ID: 9818549
Bingo
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question