Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 9:13 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Date Variables
PostPosted: May 11th, 2012, 12:17 am 
Offline

Joined: May 28th, 2007, 11:39 pm
Posts: 81
Location: Wirral, UK
Opus: v7.03
OS: XP / Win 7
System: Various
Hi - I want to set a variable to show the date 30 days from the current date (System_Date_Full date). I had hoped that setting a variable (say 'Newdate') to be equal to System_date_full, then adding 30 to this variable, would get the variable to the date thirty days from now, but it didn't work. Wondering if there's some script I could put in that would do this job - have searched the forums but can't find anything. Any advice would be welcomed.

_________________
Opus Pro. v6.0
XP hOME
Intel Core 2 Duo 6550, 2 gb Ram
iNTEGRATED graphics card


For this message Paulshistory has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Date Variables
PostPosted: May 11th, 2012, 9:14 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Adds 30 days to current date:

Code:
//get current date
myDate = new Date()
//convert to milliseconds
var ms = Date.parse(myDate)
//Add 30 days worth of milliseconds
ms = ms + (86400000*30)
//convert back to date
myDate.setTime(ms)


I wouldn't advice using this sort of technique if it's for some form of trial security.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: Date Variables
PostPosted: May 13th, 2012, 11:34 am 
Offline

Joined: May 28th, 2007, 11:39 pm
Posts: 81
Location: Wirral, UK
Opus: v7.03
OS: XP / Win 7
System: Various
Hi - thanks for the post, but couldn't get it to work.

I entered the script:

//get current date
date_payment_overdue = new Date()
//convert to milliseconds
var ms = Date.parse(date_payment_overdue)
//Add 30 days worth of milliseconds
ms = ms + (86400000*30)
//convert back to date
date_payment_overdue.setTime(ms)

However, when I viewed the date_payment_overdue, it hadn't been advanced by time at all - still said Sun 13 May 2012 11:32:07

Also, I only need it to be in the same syntax as the System_date_full variable - ie 12 Jun 2012.

Any further help would be appreciated

_________________
Opus Pro. v6.0
XP hOME
Intel Core 2 Duo 6550, 2 gb Ram
iNTEGRATED graphics card


For this message Paulshistory has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Date Variables
PostPosted: May 13th, 2012, 6:50 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Seems to work fine here. I added a debug line to the end and it spat out the 12th June from today's date.

Code:
Debug.trace(date_payment_overdue)


As for the format, the variable (date_payment_overdue) is a date object, you can use Opus' commands, such as getMonth() to pull the data and then format it. The list is in the help section.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 41 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group