Solved

date format

Posted on 2003-11-25
7
761 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now