Hi All,

I need a vbscript which with record the current system date and time in the format [YYYY-MM-DD HH:MM:SS] and append the same in between a string in a ini file ;
Say:

ACCEPT, 90.136.18.140,Security Manager, 2009-04-20 00:42:11, PERPETUAL, 4000, BIgui"

Thank you in advance.
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Is there some reason why you have re-jigged your question http://itninja.com/question/gnu,-freeware-and-shareware-programs-to-cloning9460 and posted it in a different forum? The answer is the same (well, from me, anyway). Use the class - it will save you a lot of work.

As for the date part, you can do all sorts of re-jigging with string manipulation. Here's a ChangeDateFormat function, to which you could add different formats (to save re-writing the same code over and over). It takes the date (normally from the Now() statement) and uses the various date/time handling statements like Day, Month, Year and so on to split the return value from Now() into its constituent parts. It then re-constitutes them according to a format integer passed in to the function.'//=========================================================================================================
'// Name: ChangeDateFormat
'// Purpose: Converts date to different formats
'// Also adds leading zeroes to days, hours, minutes & seconds
'// Input: strDate - a string containing the date in its current format
'// intFormatToUse - an integer indicating which format to convert TO
'// Output: strNewDate - a string to contain the converted date
'// Returns: True/False
'//
'//=========================================================================================================
Function ChangeDateFormat(ByVal strDate, ByVal intFormatToUse, ByRef strNewDate)

Dim strYear
Dim strMonth
Dim strDay
Dim strHour
Dim strMinute
Dim strSecond

ChangeDateFormat = False

If Len(strDate) = 0 Or IsNull(strDate) = True Then
strNewDate = ""
Exit Function
End If

ChangeDateFormat = True

strDay = Day(strDate)
strMonth = Month(strDate)
strYear = Year(strDate)
strHour = Hour(strDate)
strMinute = Minute(strDate)
strSecond = Second(strDate)

If strMonth < 10 Then
strMonth = "0" & strMonth
End If

If strDay < 10 Then
strDay = "0" & strDay
End If

If strHour < 10 Then
strHour = "0" & strHour
End If

If strMinute < 10 Then
strMinute = "0" & strMinute
End If

If strSecond < 10 Then
strSecond = "0" & strSecond
End If

Select Case intFormatToUse
Case intDateFormat
strNewDate = strDay & "-" & strMonth & "-" & strYear

Case intTimeFormat
strNewDate = strHour & ":" & strMinute & ":" & strSecond

Case intDateTimeFormat
strNewDate = strDay & "-" & strMonth & "-" & strYear & " " & strHour & ":" & strMinute & ":" & strSecond

Case intDateSpaceFormat
blnResult = GetMonthName(intMonth, True, strMonth)
strNewDate = strDay & " " & strMonth & " " & strYear

Case intDateTimeSpaceFormat
blnResult = GetMonthName(intMonth, True, strMonth)
strNewDate = strDay & " " & strMonth & " " & strYear & " " & strHour & ":" & strMinute & ":" & strSecond

Case intGPOFormat
strNewDate = strYear & strMonth & strDay & strHour & strMinute & strSecond

Case intWMIFormat
strNewDate = strYear & strMonth & strDay & strHour & strMinute & "00.000000+***"

Case Else
strNewDate = strDay & "-" & strMonth & "-" & strYear & " " & strHour & ":" & strMinute & ":" & strSecond
End Select

End Function
Answered 06/24/2009 by: VBScab
Red Belt

Please log in to comment
0
Hi

I have not rejigged my question

Kindly read my question carefully, this is for a totally different issue.

My previous question was pertaining

"which will read a ini file with a keyword and when it finds out the keyword it will delete the line that contains the keyword "

Hope this answers your query.
Answered 06/24/2009 by: bubble_buzz21
Senior Yellow Belt

Please log in to comment
0
Oh, come on! LOL

Use the class file. It'll do what you want and some.For the other parts of the string you want to add, get the value with the GetINIValue function from the class, use Split with the comma as the separator, replace element 4 (actually 3, as arrays are zero-based) with the re-formatted date, add the remaining elements, then write the new value using WriteINIValue.

How hard is that?
Answered 06/24/2009 by: VBScab
Red Belt

Please log in to comment
0
Hi

Rather than using all the cumbersome scripts here is a script which will serve the purpose :

sDate = Date
Dim FTime
Dim MTime
MTime = FormatDateTime(Time, 4)

FTime = Right("0" & Hour(MTime), 2) & ":" & Right("0" & Minute(MTime), 2) & ":" & Right("0" & Second(Time), 2)

Wscript.Echo "Date is: " & Year(sDate) & "-" & Right("0" & Month(sDate),2) & "-" & Right("0" & Day(sDate), 2) & " " & FTime
Answered 06/26/2009 by: bubble_buzz21
Senior Yellow Belt

Please log in to comment
0
Eventually, when you've written more or less the same code for the 5th or 6th time, you'll see the error of your ways and build a date-formatting function.
Answered 06/26/2009 by: VBScab
Red Belt

Please log in to comment
0
It for people who can finish the job in 7 or 8 lines rather than going thru codes which are over 450 lines and getting no result.

Its good to have knowledge but bad when you exploit it.
Answered 06/26/2009 by: bubble_buzz21
Senior Yellow Belt

Please log in to comment
0
people who can finish the job in 7 or 8Those people are the same people whose scripts fall over when they encounter basic errors...
Answered 06/29/2009 by: VBScab
Red Belt

Please log in to comment
0
I guess there are people who have no better work in the world and who think they have taken the monoply over this site and can sit and comment on others blog in any way they feel like.

No one learns scripting in one day dude. People make mistakes but you should know how to reply guess you shold first learn that.

SO YOU BETTER NOT COMMENT ON MY QUERIES FROM NEXT TIME.
Answered 06/29/2009 by: bubble_buzz21
Senior Yellow Belt

Please log in to comment
0
No one learns scripting in one day dude. That's right. And they won't ever learn proper coding techniques from bad scripts.
SO YOU BETTER NOT COMMENT ON MY QUERIES FROM NEXT TIME. Seriously? Why not? What's going to happen? Should I check my life insurance? Or my will?
Answered 06/29/2009 by: VBScab
Red Belt

Please log in to comment
0
Ya sure dude you can do that if you want to ...... seems people like you have more time to pick up fight then resolving issues. This just shows your arrogance.

Anyways you couldnt resolve my issue so better dont give me advice save it for yourself.
Answered 06/29/2009 by: bubble_buzz21
Senior Yellow Belt

Please log in to comment
0
seems people like you have more time to pick up fight then resolving issuesEr, remind who it was that started making "threats"?you couldnt resolve my issue "Dude", I could have resolved it in my sleep: I write software which people pay for. You, however, seem to belong to the modern school of software development - ask other people to do the work for free and then slag them off when the going gets even marginally beyond page five of "Scripting For Dummies." Cheerio.
Answered 06/29/2009 by: VBScab
Red Belt

Please log in to comment
0
Ur code shows dat u really write in ur sleep and people pay for a that.... then why dont u excuse urself from my queries n go to "people" who can afford to pay you for ur script.

BTW if you follow the mail thread you can c who started all the so called great comments...i just posted the script which worked for me so , n whats so wrong if your script dint work out for me..i guess it was not meant an offence for u if my small script served the purpose rather then using a bulky script...dude guess u take things to personally when ur resolution dont work out.

I think this is a free site for resolution and you are too much in need of money no wonder u always mention that.

Think global recession is taking a toll over evryone.
Answered 06/29/2009 by: bubble_buzz21
Senior Yellow Belt

Please log in to comment
0
Not a constructive discussion here and nobody likes to see attacks here.

No finger pointing, I'm just locking the thread in an effort to squash this
Answered 06/30/2009 by: bkelly
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity