• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

Need to get computed field populated via picklist back into date/time format??

Hello EE,

I am having some problems using @(Month) on a field as it is in text mode...

The field in question LeOOODate is populated via the following script, into a computed field...  ( default value LeOOODate )

Sub Click(Source As Button)
      Dim ws As New NotesUIWorkSpace
      Dim ses As New NotesSession
      Dim db As NotesDatabase
      Dim dc As NotesdocumentCollection
      Dim doc As NotesDocument
      Dim retVal As Variant
      Dim fieldVal As Variant
      
      Set db = ses.CurrentDatabase
      Set dc = db.UnprocessedDocuments
      
      retVal = ws.Pickliststrings(PICKLIST_CUSTOM, False, db.server, db.filepath, _
      "(LUOOOTrips)" , "Trips" , "Select the Direct Inhome Trip", 5)
      
      fieldVal = Evaluate({@Explode("} & retVal(0) & {";"###")})
      
      Set doc = dc.GetFirstDocument
      While Not doc Is Nothing
            doc.LeOOODate = fieldVal(0)
            doc.LeOOOID = fieldVal(1)
            doc.LeOOOLoc = fieldVal(2)
            doc.LeOOOState = fieldVal(3)
            doc.LeInhome = fieldVal(4)
            doc.save True, True
            Set doc = dc.GetNextDocument(doc)    
      Wend
      ws.ViewRefresh
End Sub

The data comes into my field LeOOODate OK - but in text format (  as using @Month display Incorrect Data message... )
How do I make it come straight into the field as a date/time..?  I have stipulated on the destination form that the field is a Date/Time field ( computed )  but I think I may need to do this in the LS.

If I change the field type to Editable and open edit save doc it works fine but I don't want this field able to be modified...

I have seriously done my head in with this!! Please help me --  how I can get this data inserted as date??

Just incase I am going completely the wrong way about this I am trying to utilise @Month & @Year to extract the date data, display it in a column along with other fields...
eg...   SalesTrip + SalesLocation + TripMonth + TripYear

I hope this makes sense!!!
Much appreciated,

Broad

0
BroadAustralia
Asked:
BroadAustralia
  • 4
2 Solutions
 
marilyngCommented:
Hi BroadAustralia,
So, if I understand, you've concatenated several values into a column and are retrieving them to put into a field.

Ok..

Dim ndt as New NotesDatetime(format(fieldVal(0),"mm/dd/yyyy") + " 12:00:00 AM")

Or
dim ndf as NotesDateTime("")
set ndt = new NotesDatetime(format(fieldVal(0),"mm/dd/yyyy"))


If fieldVal(0) is a date only, then you can set the time with a string, or use the settime command to set it to midnight.

When assigning to a field, you use the lslocaltime else you will get an error.

doc.leOOODate = ntd.lsLocalTime

Check the NotesDateTime Class for all the properties and methods.
Then you can use the  year(ntd), month, day, etc.

If fieldVal(0) is null, then your date is one of those 1/31/1899 dates.  So validate by checking the year value.

Regards!
0
 
marilyngCommented:
marilyng,
> ndf
ndt << oops, typo.
0
 
cezarFCommented:
or doc.LeOOODate = cdat(fieldVal(0))
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
marilyngCommented:
You know, I tend to always do the NotesDateTime because i want to make sure that the date is collected and manipulated in the correct time frame.  I can't really do this with cdat, although in a pinch it's a fast way to convert a date.
0
 
BroadAustraliaAuthor Commented:
Hi sorry for the time lapse!

Cezar I used your solution as I was in a hurry & I didn't need to worry about time zone ( is this way you use other method Marliyn? time*zones*?  )..

PS are the Redbooks the best reference source for checking Class properties / methods?

Broad.
0
 
marilyngCommented:
NO, I use the NotesdateTime because I can manipulate it better. :)   One is a LS Class,the other is a VB class.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now