FormatDateTime(, "yyyyMMddHHmm IN VB6

trying to reformat my data from what it pulls to yyyyMM and etc.

Page 1 of 1

3 Replies - 17335 Views - Last Post: 09 June 2009 - 05:11 AM Rate Topic: -----

#1 MoistFist  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 101
  • Joined: 02-June 09

FormatDateTime(, "yyyyMMddHHmm IN VB6

Post icon  Posted 04 June 2009 - 01:44 PM

I need help trying to get my Format date to spit out right , i get an error that its invalid, I want my 'FormatDateTime(EPRDateDish, "yyyyMMddHHmm' to spit out the EPRDateDish string in the date that it pulls from my database, but all i tend to get is the format. Any ideas


	If dr2.Item("DischargeDateTime").ToString = "" And dr2.Item("AdmitDateTime").ToString <> "" Then
					'Do nothing! patient is active in EPR'

				ElseIf dr2.Item("DischargeDateTime").ToString = "" And dr2.Item("AdmitDateTime").ToString = "" Then
					'Send an A03 to discharge patient'



					EPRAdmitDate = dr2.Item("AdmitDateTime").ToString
					EPRLocation = dr2.Item("OutpatientLocationID").ToString
					EPRRoomID = dr2.Item("RoomID").ToString
					EPRBedID = dr2.Item("Bed").ToString
					EPRName = dr2.Item("Name").ToString
					EPRAcctNum = dr2.Item("AccountNumber").ToString
					EPRUnitNum = dr2.Item("UnitNumber").ToString
				  [b]  EPRDateDish = Date2[/b]


					sMessage = ""
					sMessage = "MSH|^~\&||QMIDEMO|ADT^A03|14624160|P|2.10|" & vbCr
					sMessage = sMessage & "EVN|A03|" & Format(Now(), "yyyyMMddHHmm") & vbCr
					sMessage = sMessage & "PID|||" & EPRUnitNum & "^^/>||" & EPRName & "|||||||||||||" & EPRAcctNum & "||" & vbCr
					sMessage = sMessage & "PV1||I|" & EPRLocation & "^" & EPRRoomID & "^" & EPRBedID & "|||" & EPRLocation & "^" & EPRRoomID & "^" & EPRBedID & "||^|^||||||||^, ||||||||||||||||||||||713||PRE|||" & EPRAdmitDate & "||" & [b]FormatDateTime(EPRDateDish, "yyyyMMddHHmm") [/b]& "||"
					sMessage = Chr(11) + sMessage + Chr(28) + Chr(13)

					oWrite = File.AppendText(sPath)
					oWrite.WriteLine(sMessage)
					oWrite.Flush()
					oWrite.Close()


Is This A Good Question/Topic? 0
  • +

Replies To: FormatDateTime(, "yyyyMMddHHmm IN VB6

#2 sloanthrasher  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 18
  • Joined: 31-May 09

Re: FormatDateTime(, "yyyyMMddHHmm IN VB6

Posted 04 June 2009 - 05:00 PM

When you are building the sMessage string, you are using the expression

Quote

FormatDateTime(EPRDateDish, "yyyyMMddHHmm")
.

The problem might be when you assign the value into EPRDateDish, the type isn't shown in your code example. If it is a string, it won't work. Date2 and EPRDateDish should both be DateTime types. FormatDateTime expects a DateTime type.

You could use CDate(EPRDateDish) inside the formatdatetime function, but that might be error prone if the string isn't formatted properly.
Was This Post Helpful? 0
  • +
  • -

#3 Jupiter 2  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 40
  • Joined: 05-June 09

Re: FormatDateTime(, "yyyyMMddHHmm IN VB6

Posted 05 June 2009 - 08:11 AM

When you type in FormatDateTime it gives you options to choose - ie Short date long date etc
Try just a plain format -
[code]
MsgBox Format(PRDateDish,"yy-mm-dd-hh-mm", vbUseSystemDayOfWeek)
]/code]
Was This Post Helpful? 0
  • +
  • -

#4 MoistFist  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 101
  • Joined: 02-June 09

Re: FormatDateTime(, "yyyyMMddHHmm IN VB6

Posted 09 June 2009 - 05:11 AM

Thanks guys i used Format(EPRDishDate, "yyyyMMddHHmm") I feel like an idiot though because the whole time i had the write syntax but i was trying to pull data from the wrong if statement. So basically the reason it wasn't working was because i was pulling null data lol. thanks for the help again
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1