assigning dates to a date variable with syntax

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

assigning dates to a date variable with syntax

Jeff A

 

I haven’t messed with date variables much before, but am now needing to create a simple date variable in format dd.mmm.yy hh:mm (or as close as possible) and then assign values to that variable (both tasks with syntax rather than through direct entry).

 

I’m finding it difficult to find info on this on the web or figure it out on my own although it should be simple. I don’t need to do any manipulations/calculations with it (if that matters).

 

I just need something like…

 

Date TestDate (d, dd.mmm.yy. hh:mm) . etc., etc.

 

Do if (ID = 3).

  Compute/assign (whatever)  Testdate = 08.Jan.19 05:30 .

End if.

 

I’m likely overlooking something simple.

 

Thanks in advance.

 

Jeff

 

 

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: assigning dates to a date variable with syntax

Bruce Weaver
Administrator
* Create a dataset.
DATA LIST LIST / junk(F1).
BEGIN DATA
1
END DATA.

* Notice the DATE.DMY and TIME.HMS functions on the next line.
COMPUTE Testdate = DATE.DMY(8,1,2019) + TIME.HMS(5,30,0).
FORMATS Testdate(DATETIME25).
LIST.

OUTPUT:
junk                  Testdate
 
  1       08-JAN-2019 05:30:00



Jeff-2 wrote

> I haven't messed with date variables much before, but am now needing to
> create a simple date variable in format dd.mmm.yy hh:mm (or as close as
> possible) and then assign values to that variable (both tasks with syntax
> rather than through direct entry).
>
>  
>
> I'm finding it difficult to find info on this on the web or figure it out
> on
> my own although it should be simple. I don't need to do any
> manipulations/calculations with it (if that matters).
>
>  
>
> I just need something like.
>
>  
>
> Date TestDate (d, dd.mmm.yy. hh:mm) . etc., etc.
>
>  
>
> Do if (ID = 3).
>
>   Compute/assign (whatever)  Testdate = 08.Jan.19 05:30 .
>
> End if.
>
>  
>
> I'm likely overlooking something simple.
>
>  
>
> Thanks in advance.
>
>  
>
> Jeff
>
>  
>
>  
>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: assigning dates to a date variable with syntax

Jeff A
In reply to this post by Jeff A
David and Bruce's info was great help and works, but I'm looking everywhere
for documentation on the date formats that both used and can't find what I
need.

E.g., David mentioned FORMATS MyDateToday (DATETIME17) and Bruce mentioned
FORMATS Testdate(DATETIME25).

I'm trying to format for dd-mmm-yy hh:mm rather than dd-mmm-yyyy hh:mm and
can do this in variable-view of the data editor, but can find no useful
documentation anywhere on the web or command syntax reference that lists the
various DATETIME formats so that I can know the various data formats to do
this formatting with syntax. These don't seem to correspond to the widths or
columns listed in the variable view area and my experimentation is coming up
with mostly error messages.

Where can I find info about this? ...or perhaps there's simply something I
don't understand properly.

Best,

Jeff







-----Original Message-----
From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Bruce
Weaver
Sent: Saturday, 12 January 2019 1:01 AM
To: [hidden email]
Subject: **JUNK** Re: assigning dates to a date variable with syntax

* Create a dataset.
DATA LIST LIST / junk(F1).
BEGIN DATA
1
END DATA.

* Notice the DATE.DMY and TIME.HMS functions on the next line.
COMPUTE Testdate = DATE.DMY(8,1,2019) + TIME.HMS(5,30,0).
FORMATS Testdate(DATETIME25).
LIST.

OUTPUT:
junk                  Testdate
 
  1       08-JAN-2019 05:30:00



Jeff-2 wrote

> I haven't messed with date variables much before, but am now needing
> to create a simple date variable in format dd.mmm.yy hh:mm (or as
> close as
> possible) and then assign values to that variable (both tasks with
> syntax rather than through direct entry).
>
>  
>
> I'm finding it difficult to find info on this on the web or figure it
> out on my own although it should be simple. I don't need to do any
> manipulations/calculations with it (if that matters).
>
>  
>
> I just need something like.
>
>  
>
> Date TestDate (d, dd.mmm.yy. hh:mm) . etc., etc.
>
>  
>
> Do if (ID = 3).
>
>   Compute/assign (whatever)  Testdate = 08.Jan.19 05:30 .
>
> End if.
>
>  
>
> I'm likely overlooking something simple.
>
>  
>
> Thanks in advance.
>
>  
>
> Jeff
>
>  
>
>  
>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the command. To leave the
> list, send the command SIGNOFF SPSSX-L For a list of commands to
> manage subscriptions, send the command INFO REFCARD





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: assigning dates to a date variable with syntax

Rick Oliver

On Fri, Jan 11, 2019 at 4:46 PM Jeff <[hidden email]> wrote:
David and Bruce's info was great help and works, but I'm looking everywhere
for documentation on the date formats that both used and can't find what I
need.

E.g., David mentioned FORMATS MyDateToday (DATETIME17) and Bruce mentioned
FORMATS Testdate(DATETIME25).

I'm trying to format for dd-mmm-yy hh:mm rather than dd-mmm-yyyy hh:mm and
can do this in variable-view of the data editor, but can find no useful
documentation anywhere on the web or command syntax reference that lists the
various DATETIME formats so that I can know the various data formats to do
this formatting with syntax. These don't seem to correspond to the widths or
columns listed in the variable view area and my experimentation is coming up
with mostly error messages.

Where can I find info about this? ...or perhaps there's simply something I
don't understand properly.

Best,

Jeff







-----Original Message-----
From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Bruce
Weaver
Sent: Saturday, 12 January 2019 1:01 AM
To: [hidden email]
Subject: **JUNK** Re: assigning dates to a date variable with syntax

* Create a dataset.
DATA LIST LIST / junk(F1).
BEGIN DATA
1
END DATA.

* Notice the DATE.DMY and TIME.HMS functions on the next line.
COMPUTE Testdate = DATE.DMY(8,1,2019) + TIME.HMS(5,30,0).
FORMATS Testdate(DATETIME25).
LIST.

OUTPUT:
junk                  Testdate

  1       08-JAN-2019 05:30:00



Jeff-2 wrote
> I haven't messed with date variables much before, but am now needing
> to create a simple date variable in format dd.mmm.yy hh:mm (or as
> close as
> possible) and then assign values to that variable (both tasks with
> syntax rather than through direct entry).
>

>
> I'm finding it difficult to find info on this on the web or figure it
> out on my own although it should be simple. I don't need to do any
> manipulations/calculations with it (if that matters).
>

>
> I just need something like.
>

>
> Date TestDate (d, dd.mmm.yy. hh:mm) . etc., etc.
>

>
> Do if (ID = 3).
>
>   Compute/assign (whatever)  Testdate = 08.Jan.19 05:30 .
>
> End if.
>

>
> I'm likely overlooking something simple.
>

>
> Thanks in advance.
>

>
> Jeff
>

>

>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the command. To leave the
> list, send the command SIGNOFF SPSSX-L For a list of commands to
> manage subscriptions, send the command INFO REFCARD





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: assigning dates to a date variable with syntax

Jon Peck
In reply to this post by Jeff A
All the variable formats are listed in the CSR under Universals > Variable Types and Formats and Date and Time Formats in particular.  However, I don't think you can get two digit years with datetime formats.  You can convert a datetime value to a string with that format using a bit of programmability.  I can show you that if it would be useful.

On Fri, Jan 11, 2019 at 3:46 PM Jeff <[hidden email]> wrote:
David and Bruce's info was great help and works, but I'm looking everywhere
for documentation on the date formats that both used and can't find what I
need.

E.g., David mentioned FORMATS MyDateToday (DATETIME17) and Bruce mentioned
FORMATS Testdate(DATETIME25).

I'm trying to format for dd-mmm-yy hh:mm rather than dd-mmm-yyyy hh:mm and
can do this in variable-view of the data editor, but can find no useful
documentation anywhere on the web or command syntax reference that lists the
various DATETIME formats so that I can know the various data formats to do
this formatting with syntax. These don't seem to correspond to the widths or
columns listed in the variable view area and my experimentation is coming up
with mostly error messages.

Where can I find info about this? ...or perhaps there's simply something I
don't understand properly.

Best,

Jeff







-----Original Message-----
From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Bruce
Weaver
Sent: Saturday, 12 January 2019 1:01 AM
To: [hidden email]
Subject: **JUNK** Re: assigning dates to a date variable with syntax

* Create a dataset.
DATA LIST LIST / junk(F1).
BEGIN DATA
1
END DATA.

* Notice the DATE.DMY and TIME.HMS functions on the next line.
COMPUTE Testdate = DATE.DMY(8,1,2019) + TIME.HMS(5,30,0).
FORMATS Testdate(DATETIME25).
LIST.

OUTPUT:
junk                  Testdate

  1       08-JAN-2019 05:30:00



Jeff-2 wrote
> I haven't messed with date variables much before, but am now needing
> to create a simple date variable in format dd.mmm.yy hh:mm (or as
> close as
> possible) and then assign values to that variable (both tasks with
> syntax rather than through direct entry).
>

>
> I'm finding it difficult to find info on this on the web or figure it
> out on my own although it should be simple. I don't need to do any
> manipulations/calculations with it (if that matters).
>

>
> I just need something like.
>

>
> Date TestDate (d, dd.mmm.yy. hh:mm) . etc., etc.
>

>
> Do if (ID = 3).
>
>   Compute/assign (whatever)  Testdate = 08.Jan.19 05:30 .
>
> End if.
>

>
> I'm likely overlooking something simple.
>

>
> Thanks in advance.
>

>
> Jeff
>

>

>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the command. To leave the
> list, send the command SIGNOFF SPSSX-L For a list of commands to
> manage subscriptions, send the command INFO REFCARD





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: assigning dates to a date variable with syntax

Jon Peck
The columns field applies only to the Data Editor and is generally useless.  It can be useful, though, if you have a long string but want to show only part of it in the DE view or want to save display space for a numeric value.  This is strictly a Data Editor display property.  

The width field is slightly more useful as it limits the display width of the value in output, but in pivot tables, the width isn't usually important.  Of course for strings, the width determines the number of bytes the variable can hold.  It has no effect on the internal value of numeric variables as they always take 64 bits (double precision floating point).  However, the formats generally triage the value to fit the designated width squeezing out characters in the display like the thousands-delimiting comma or trailing decimals but doesn't affect the internal value.  You can see this especially with date formats.



On Fri, Jan 11, 2019 at 4:55 PM Jeff <[hidden email]> wrote:

I saw that, particularly Table 2 in Chapter 2, but still don’t get it fully.

 

What I seem to get is that most modern dates are stored as 11 digits representing the number of seconds since Oct 14, 1582  so that 13795401600 represents midnight, 11 December, 2019.

 

The spss formats don’t alter how that number is stored, but only how it’s displayed within the SPSS data editor window. The Formats XXX(Datetime25) or Formats XXX(Datetime17) syntax alter the display. …but I’m not grasping what exactly the 17 and the 25 represent in David and Bruce’s examples. Do these values have to do with the “width” or “columns” I’m seeing in the variable view window of spss? I understand that most date formats would have 0 for the “Decimals” unless you’re interested in fractions of a second (I’m not), but don’t get the width and columns.

 

Best,

 

Jeff

 

 

 

From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Jon Peck
Sent: Saturday, 12 January 2019 9:02 AM
To: [hidden email]
Subject: Re: assigning dates to a date variable with syntax

 

All the variable formats are listed in the CSR under Universals > Variable Types and Formats and Date and Time Formats in particular.  However, I don't think you can get two digit years with datetime formats.  You can convert a datetime value to a string with that format using a bit of programmability.  I can show you that if it would be useful.

 

On Fri, Jan 11, 2019 at 3:46 PM Jeff <[hidden email]> wrote:

David and Bruce's info was great help and works, but I'm looking everywhere
for documentation on the date formats that both used and can't find what I
need.

E.g., David mentioned FORMATS MyDateToday (DATETIME17) and Bruce mentioned
FORMATS Testdate(DATETIME25).

I'm trying to format for dd-mmm-yy hh:mm rather than dd-mmm-yyyy hh:mm and
can do this in variable-view of the data editor, but can find no useful
documentation anywhere on the web or command syntax reference that lists the
various DATETIME formats so that I can know the various data formats to do
this formatting with syntax. These don't seem to correspond to the widths or
columns listed in the variable view area and my experimentation is coming up
with mostly error messages.

Where can I find info about this? ...or perhaps there's simply something I
don't understand properly.

Best,

Jeff







-----Original Message-----
From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Bruce
Weaver
Sent: Saturday, 12 January 2019 1:01 AM
To: [hidden email]
Subject: **JUNK** Re: assigning dates to a date variable with syntax

* Create a dataset.
DATA LIST LIST / junk(F1).
BEGIN DATA
1
END DATA.

* Notice the DATE.DMY and TIME.HMS functions on the next line.
COMPUTE Testdate = DATE.DMY(8,1,2019) + TIME.HMS(5,30,0).
FORMATS Testdate(DATETIME25).
LIST.

OUTPUT:
junk                  Testdate

  1       08-JAN-2019 05:30:00



Jeff-2 wrote


> I haven't messed with date variables much before, but am now needing
> to create a simple date variable in format dd.mmm.yy hh:mm (or as
> close as
> possible) and then assign values to that variable (both tasks with
> syntax rather than through direct entry).
>

>
> I'm finding it difficult to find info on this on the web or figure it
> out on my own although it should be simple. I don't need to do any
> manipulations/calculations with it (if that matters).
>

>
> I just need something like.
>

>
> Date TestDate (d, dd.mmm.yy. hh:mm) . etc., etc.
>

>
> Do if (ID = 3).
>
>   Compute/assign (whatever)  Testdate = 08.Jan.19 05:30 .
>
> End if.
>

>
> I'm likely overlooking something simple.
>

>
> Thanks in advance.
>

>
> Jeff
>

>

>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> [hidden email]

>  (not to SPSSX-L), with no body text except the command. To leave the
> list, send the command SIGNOFF SPSSX-L For a list of commands to
> manage subscriptions, send the command INFO REFCARD





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


 

--

Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: assigning dates to a date variable with syntax

Jeff A

 

Got it.

 

…figured it was something simple.

 

…read right past the distinction between Data and DateTime formats in the CSR.

 

Thanks.

 

Jeff

 

 

 

From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Jon Peck
Sent: Saturday, 12 January 2019 11:00 AM
To: [hidden email]
Subject: Re: assigning dates to a date variable with syntax

 

You are pretty close, but you started with Date and ended with DateTime.  DateTime has a minimum width of 17, but Date has a minimum of 9.  So at the end you should specify DATE9, not DATETIME9.

 

None of those format changes affects the actual values - just the display.

 

On Fri, Jan 11, 2019 at 5:48 PM Jeff <[hidden email]> wrote:

 

In my experimentation to understand…

 

I start with a numeric value for variable XXX with 11 digits 13795401600  That’s 11 Dec 2019 midnight. By default with a numeric value, the variable view window shows Width of 8, decimals 2, columns 8

 

Let’s say I want to alter the display, so I go into variable view and select date format and dd-mmm-yy since that’s the way I want the value displayed.

 

When I do, the variable view window tells me that it’s set XXX to Type “Date”, the Width to 9, the decimals to 0, and it’s left the Columns at 8. The width of 9 makes sense since there are 9 digits necessary to display dd-mmm-yy .

 

If I want to alter to dd-mmm-yyyy format (for 4 digit rather than 2 digit year) and do this through the variable view window, when I select that format it just switches the width to 11 and leaves all else alone. I get a proper display. …makes sense since you need 11 digits/characters to display dd-mm-yyyy.

 

If I run Formats XXX (DateTime17) in syntax, this alters to width 17, columns 17 and I get a display with 4 digit year display and hours and minutes are now correctly displayed.

 

If I run Formats XXX (DateTime25) in syntax, this alters to width 25, columns 25 and I get a correct display with 4 digit year display and hours and minutes are displayed.

 

If I run Formats XXX (DateTime11) or DateTime9 in syntax, to try to go back to the dd-mmm-yy or dd-mmm-yyyy formatting that I started with, I get error messages.

 

I’m now seeing that the columns is simply how wide the variable appears in the DV window and is largely irrelevant, but I’m not understanding why I can’t specify DateTime9 format within syntax to specify the dd-mmm-yy format that I can get from within the VV window.

 

Perhaps there is something I’m not grasping.

 

Jeff

 

 

 

From: Jon Peck <[hidden email]>
Sent: Saturday, 12 January 2019 10:12 AM
To: Jeff <[hidden email]>
Cc: SPSS List <[hidden email]>
Subject: Re: [SPSSX-L] assigning dates to a date variable with syntax

 

The columns field applies only to the Data Editor and is generally useless.  It can be useful, though, if you have a long string but want to show only part of it in the DE view or want to save display space for a numeric value.  This is strictly a Data Editor display property.  

 

The width field is slightly more useful as it limits the display width of the value in output, but in pivot tables, the width isn't usually important.  Of course for strings, the width determines the number of bytes the variable can hold.  It has no effect on the internal value of numeric variables as they always take 64 bits (double precision floating point).  However, the formats generally triage the value to fit the designated width squeezing out characters in the display like the thousands-delimiting comma or trailing decimals but doesn't affect the internal value.  You can see this especially with date formats.

 

 

 

On Fri, Jan 11, 2019 at 4:55 PM Jeff <[hidden email]> wrote:

I saw that, particularly Table 2 in Chapter 2, but still don’t get it fully.

 

What I seem to get is that most modern dates are stored as 11 digits representing the number of seconds since Oct 14, 1582  so that 13795401600 represents midnight, 11 December, 2019.

 

The spss formats don’t alter how that number is stored, but only how it’s displayed within the SPSS data editor window. The Formats XXX(Datetime25) or Formats XXX(Datetime17) syntax alter the display. …but I’m not grasping what exactly the 17 and the 25 represent in David and Bruce’s examples. Do these values have to do with the “width” or “columns” I’m seeing in the variable view window of spss? I understand that most date formats would have 0 for the “Decimals” unless you’re interested in fractions of a second (I’m not), but don’t get the width and columns.

 

Best,

 

Jeff

 

 

 

From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Jon Peck
Sent: Saturday, 12 January 2019 9:02 AM
To:
[hidden email]
Subject: Re: assigning dates to a date variable with syntax

 

All the variable formats are listed in the CSR under Universals > Variable Types and Formats and Date and Time Formats in particular.  However, I don't think you can get two digit years with datetime formats.  You can convert a datetime value to a string with that format using a bit of programmability.  I can show you that if it would be useful.

 

On Fri, Jan 11, 2019 at 3:46 PM Jeff <[hidden email]> wrote:

David and Bruce's info was great help and works, but I'm looking everywhere
for documentation on the date formats that both used and can't find what I
need.

E.g., David mentioned FORMATS MyDateToday (DATETIME17) and Bruce mentioned
FORMATS Testdate(DATETIME25).

I'm trying to format for dd-mmm-yy hh:mm rather than dd-mmm-yyyy hh:mm and
can do this in variable-view of the data editor, but can find no useful
documentation anywhere on the web or command syntax reference that lists the
various DATETIME formats so that I can know the various data formats to do
this formatting with syntax. These don't seem to correspond to the widths or
columns listed in the variable view area and my experimentation is coming up
with mostly error messages.

Where can I find info about this? ...or perhaps there's simply something I
don't understand properly.

Best,

Jeff







-----Original Message-----
From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Bruce
Weaver
Sent: Saturday, 12 January 2019 1:01 AM
To: [hidden email]
Subject: **JUNK** Re: assigning dates to a date variable with syntax

* Create a dataset.
DATA LIST LIST / junk(F1).
BEGIN DATA
1
END DATA.

* Notice the DATE.DMY and TIME.HMS functions on the next line.
COMPUTE Testdate = DATE.DMY(8,1,2019) + TIME.HMS(5,30,0).
FORMATS Testdate(DATETIME25).
LIST.

OUTPUT:
junk                  Testdate

  1       08-JAN-2019 05:30:00



Jeff-2 wrote


> I haven't messed with date variables much before, but am now needing
> to create a simple date variable in format dd.mmm.yy hh:mm (or as
> close as
> possible) and then assign values to that variable (both tasks with
> syntax rather than through direct entry).
>

>
> I'm finding it difficult to find info on this on the web or figure it
> out on my own although it should be simple. I don't need to do any
> manipulations/calculations with it (if that matters).
>

>
> I just need something like.
>

>
> Date TestDate (d, dd.mmm.yy. hh:mm) . etc., etc.
>

>
> Do if (ID = 3).
>
>   Compute/assign (whatever)  Testdate = 08.Jan.19 05:30 .
>
> End if.
>

>
> I'm likely overlooking something simple.
>

>
> Thanks in advance.
>

>
> Jeff
>

>

>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> [hidden email]

>  (not to SPSSX-L), with no body text except the command. To leave the
> list, send the command SIGNOFF SPSSX-L For a list of commands to
> manage subscriptions, send the command INFO REFCARD





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


 

--

Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


 

--

Jon K Peck
[hidden email]


 

--

Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD