Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Extract from Date
Topic Summary: How to extract Day, Month and year
Created On: 19-Nov-2008 13:29
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 19-Nov-2008 13:29
User is offline View Users Profile Print this message


Irfaan Jamal

Posts: 30
Joined: 13-Feb-2008

Hello All,

How do I extract the date, month and year from a given date by not knowing the format of it?

Thanks & Regards
Irfaan
Report this to a Moderator Report this to a Moderator
 19-Nov-2008 14:47
User is offline View Users Profile Print this message


Kevin Murphy

Posts: 120
Joined: 16-Jan-2008

I don't believe your question is specific enough. Any given date should be of type Date.

Are you trying to convert a string to a Date or extract strings from a Date or strings from a string?

-------------------------
Kevin Murphy
http://www.baselinesinc.com
Report this to a Moderator Report this to a Moderator
 19-Nov-2008 14:49
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

Look Here:
Report this to a Moderator Report this to a Moderator
 19-Nov-2008 15:22
User is offline View Users Profile Print this message


Irfaan Jamal

Posts: 30
Joined: 13-Feb-2008

Hi

I want to extract the day, month and year seperately from a given date.

For example, if the date is "19-Nov-2008"

I want to get the day as 19, month as Nov and year as 2008.

The logic should be very general that it shld give the same result irrespective of the date format.

For example, if the date was in format 19/11/2008 or 2008-11-19 or any standard date formats.

Is there a way?

Thanks & Regards
Irfaan
Report this to a Moderator Report this to a Moderator
 19-Nov-2008 17:22
User is offline View Users Profile Print this message


Pekka Mäkinen

Posts: 276
Joined: 18-Mar-2004

If your date string has the content 08/08/08, what is the date then? Might be that the first 8 is the year, or the last. But if the last is the year, is the beginning in the (American) format MM/dd or dd/MM?

Thus there can be no general method for parsing the date from a date string. In DOORS it is better to use Date variables, and if you have to transfer dates as string then agree to some strict format, e.g. http://en.wikipedia.org/wiki/ISO_8601 .

-------------------------
Pekka.Makinen@softqa.fi
SoftQA Oy -http://www.softqa.fi/

Edited: 19-Nov-2008 at 17:24 by Pekka Mäkinen
Report this to a Moderator Report this to a Moderator
 19-Nov-2008 19:41
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

There is probably a better way, but I use the attached function to do this sort of work. The problem arises when the 'Date' has seconds defined, in which case converting it to a string looks like "'09/08/04 10:52:32". Once that's detected, you strip off the seconds part "10:52:32" leaving "09/08/04", then convert that to a Date.

That date is then converted to a string and looks like "'08 September 2004", which is then parsed into its constituent parts.

See the attached function I use. It will not work for you as-is. You will need to write your own 'fGetOffset' which finds the location of a string inside another string (you would probably use the 'matches' function). Function 'fIsSubStr (is SubString) is simply fGetOffset returned as a boolean. My function 'fDateOf' is rather complicated, but you can probably duplicate it like this:
noError()
datOut = InDate
lastError()

- Louie
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.