Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
vk18
Posting Yak Master
146 Posts |
Posted - 2008-04-08 : 16:58:53
|
Guys,I am using one of the function to get military time but in that i am getting colon. Ex: 20:52, 19:50, ..... I want to eliminate the "colon". Can you guys help me with thisThanksPublic Function FormatTime(ByVal dateval As String) As String If (dateval) Is Nothing Then Return "N/A" Else Return FormatDateTime(dateval, 4) End If End Function |
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2008-04-09 : 01:40:58
|
Try thisReturn Replace(FormatDateTime(dateval, 4), ":", "") |
|
|
vk18
Posting Yak Master
146 Posts |
Posted - 2008-04-09 : 16:44:26
|
quote: Originally posted by ayamas Try thisReturn Replace(FormatDateTime(dateval, 4), ":", "")
Hi,I tried this one but i am getting the error " Overload resolution failed because no accessible Replace accepts this number of arguments" and i removed the replace but still not getting it. Any Idea? it is such a small format issue couldn't get it. Can any body help me on this?Thx |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-04-09 : 18:04:13
|
A year later and you still have not learned the basics of formatting? http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81558Why is the parameter of your function a string if it is accepting a date value? Always use proper data types for your functions, parameters, variables, etc, and that makes everything easier for you. If you use the correct data type, you can just use the ToString() method and specify whatever format string you want. - Jeffhttp://weblogs.sqlteam.com/JeffS |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2008-04-10 : 01:48:24
|
quote: Hi,I tried this one but i am getting the error " Overload resolution failed because no accessible Replace accepts this number of arguments" and i removed the replace but still not getting it. Any Idea? it is such a small format issue couldn't get it. Can any body help me on this?Thx
I dont know why are you getting that error.For me its workingDim dateval As String = "20:52"Response.Write(Replace(FormatDateTime(dateval, 4), ":", ""))By the way why you need to have that FormatDateTime when the parameter datatype is a string.Response.Write(Replace(dateval, ":", "")) |
|
|
|
|
|
|
|