Sqlserver Insertion Problem from Agent especially DateTime

Dear All,

I want to change the Dateformat from dd/MM/yyyy hh:mm to MM/dd/yyyy hh:mm:ss for inserting into sqlserver table.

can please help with code snippets?

My code:

Dim EmailReceivedDateTime As String

Dim EmailReceivedDateFormat As String

EmailReceivedDateTime = Cstr(doc.Created)

EmailReceivedDateFormat =Format$(EmailReceivedDateTime , “mm/dd/yyyy”) 'It is not working

Subject: Your Format usage requires a datevalue not a string.

I think you have several problems with your approach in code:

  1. The format feature you need requires you to supply a date variable not string.

  2. You converted your date variable to string, which seems unnecessary.

Instead try the 2 lines to replace your previous 4:

Dim EmailReceivedDateFormat As String

EmailReceivedDateFormat =Format$(doc.Created , “mm/dd/yyyy”)

-Kyle Huang