Change Text String to Date Field Content from View

Hi there,I am searching for some LotusScript code which converts me this textstring “mm.yyyy” into a dateformat. I have been told the the CDat function should do such conversions but when testing with the textstring “01.2006” it converts it to the date value of “11.1932”.

Hmm - which code / function do I need?

Any assistance is highly appreciated. Thank you.

Kind regards, Manfred

Further Reading…

I have a view with documents.

I mark several documents

I click an Action button which starts an Agent

That agent prompts for text field input in mm.yyyy

That input replaces in all selected docs the content in the date fields but is in wrong format (text instead of date) which leads to wrong categorizations and does not allow calculations on date basis.

Subject: Change Text String to Date Field Content from View

DateValue ( stringExpression ) will work, but I’d feed my stringExpression day, month, and year. So something like

DateValue ( “01/” & mm & “/” & yyyy ), if this is a valid date/time format for your os.

regards,

raphael

Subject: RE: Change Text String to Date Field Content from View

Hello Raphael,thank you for responding. I read the help on DateValue up and down and tried to apply this to my logic - unfortunately, w/o success.

Here is my code of this one simple agent

===========================

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument



Dim ws As New NotesUIWorkspace

Dim nam As NotesName

Dim msg As String

Dim response As Variant



Set db = session.CurrentDatabase

Set collection = db.UnprocessedDocuments

Set nam = session.CreateName(session.UserName)



'if no documents have been selected then exit routine

If collection.Count = 0 Then Exit Sub



msg = collection.Count & " documents have been selected for mass update. Please enter a new date."

response = ws.Prompt (PROMPT_OKCANCELEDIT, _

"Change Date...", msg, "06.2006")

If response = "" Then Exit Sub



Set doc = collection.GetFirstDocument

While Not (doc Is Nothing)

      'Here the field will be changed per doc with the value selected in the prompt

	doc.ASD_Depl_Date = response

	doc.Header_UpdName = nam.Abbreviated

	doc.Header_UpdCreated = Now()

      'Save the current document

	Call doc.Save(True, False)

	

	Set doc = collection.GetNextDocument(doc)

Wend 

End Sub

=================================

It’s only this one line where the “response” is written into the date field - but not in a dateformat.

Any clue?

Kind regards, Manfred

Subject: RE: Change Text String to Date Field Content from View

Manfred,

When you use this line, you’re feeding it mm.yyyy:

doc.ASD_Depl_Date = response

So instead, pull out the mm and the yyyy using right$/left$, or explode, or whatever you want, and then just use “01” for the day argument, assuming that you don’t have a real day value.

So then doc.ASD_Depl_Date = DateValue ( “01.” & response ), if the computer that is running this code thinks that dd.mm.yyyy is a valid date/time format.

does that help, or did I misunderstand your q?

raphael

Subject: RE: Change Text String to Date Field Content from View

Raphael - that did the trick.

Thanks a lot for your assistance.

Kindest regards, Manfred