Normal Topic Last Modified Field with 24-hr to 12-hr Time Conv. (Read 1681 times)
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Last Modified Field with 24-hr to 12-hr Time Conv.
Oct 8th, 2018 at 6:17pm
Print Post Print Post  
For anyone that wants it I wrote some code that displays your last modified date and time in a single field, converts 24-hour time to 12-hour time, as well as some date formatting, and what not.

This requires three fields.

A text box bound to a date field, called "Last_Modified_Date0", which is formatted to display the date as "2018/10/07."

A text box, bound to a time field, called "Last_Modified_Time0", which is formatted to display the time as "24 Hour Clock - 22:23."

A text box, bound to a text field, called "Last_Modified0".

FORM :: On Form Entry

Code
Select All
var vTime as Int
var vConversion as Int
var vMeridian as String
var vConvertedTime as String

//I created a two seperate fields, Last_Modified_Time0 which equals @RecordModifiedTime() and
//Last_Modified_Date0 which equals @RecordModifiedDate() because if you try to work on those commands
//directly with this program, for whatever reason, it modifies the record. I then made those two
//additional fields invisible so you don't see them on the form, but work in the background.

Last_Modified_Date0 = @RecordModifiedDate()
Last_Modified_Time0 = @RecordModifiedTime()

vTime = @Left(Last_Modified_Time0, 2)

If vTime > 12
{
	vConversion = vTime - 12
	vMeridian = "pm"
}
Else
{
	vConversion = vTime
	vMeridian = "am"
}

vConvertedTime = vConversion + ":" + @Right(Last_Modified_Time0, 2) + " " + vMeridian

//Last_Modified0 is a read only, but not greyed out, text field that displays this text on form entry.

Last_Modified0 = "Last modified " + @MONTH$(Last_Modified_Date0) + " " + @Dom(Last_Modified_Date0)
+ ", " + @YEAR(Last_Modified_Date0) + " at " + vConvertedTime + "."

//Should display as "Last modified October 7, 2018 at 2:23 pm."
 

  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Last Modified Field with 24-hr to 12-hr Time Conv.
Reply #1 - Nov 7th, 2018 at 10:32pm
Print Post Print Post  
Thanks for the sample code, actiontech.

I have used a similar tool since my early days in Q&A.  Fantastic info when analyzing history, problems, etc.  My version has one other field, the name of the User.

I track the Date/Time/User when a record is added, AND when it is modified.  So I have six fields. 

I also have a four fields for Import/Export activities.  I track the Date/Time/User/Record.  This has one more field with the Unique Record of the Source/Destination record.  Those fields are updated with the Export/Import command code.

Should be simple to add these extra fields to actiontech's code.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: Last Modified Field with 24-hr to 12-hr Time Conv.
Reply #2 - Nov 7th, 2018 at 10:46pm
Print Post Print Post  
Oh cool, thank you, I'll look at incorporating that.
  
Back to top
 
IP Logged