# convert: Fri May 27 12:43:11 CEST 2005

**URL:** <https://forum.servoy.com/t/convert-fri-may-27-1211-cest-2005/4389>\
**Category:** Classic Servoy\
**Created:** [June 20, 2005, 11:18am UTC](https://forum.servoy.com/t/convert-fri-may-27-1211-cest-2005/4389 "2005-06-20T11:18:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![r.schneider](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@r.schneider](https://forum.servoy.com/u/r.schneider)\
**Post date:** [June 20, 2005, 11:18am UTC](https://forum.servoy.com/t/convert-fri-may-27-1211-cest-2005/4389/1 "2005-06-20T11:18:41Z")

</div>

Hello!

I am trying to “slice” a text information like “Fri May 27 12:43:11 CEST 2005” into a datefield.

I have solved to seperate the date and time parts as stings.

But which method I should use to convert it into a datefield.

Thx,  
Roland

–

var jahr = utils.stringRight(datestring, 4);  
var tag = utils.stringMiddle(datestring, 9, 2);  
var monat = utils.stringMiddle(datestring, 5, 3);

var monat\_nr =1  
if (monat == “Jan”) {monat\_nr=“01”}  
if (monat == “Feb”) {monat\_nr=“02”}  
if (monat == “Mar”) {monat\_nr=“03”}  
if (monat == “Apr”) {monat\_nr=“04”}  
if (monat == “May”) {monat\_nr=“05”}  
if (monat == “Jun”) {monat\_nr=“06”}  
if (monat == “Jul”) {monat\_nr=“07”}  
if (monat == “Aug”) {monat\_nr=“08”}  
if (monat == “Sep”) {monat\_nr=“09”}  
if (monat == “Okt”) {monat\_nr=“10”}  
if (monat == “Nov”) {monat\_nr=“11”}  
if (monat == “Dez”) {monat\_nr=“12”}

date\_ = tag+‘.’+monat\_nr+‘.’+jahr;

time\_ = utils.stringMiddle(datestring, 12, ![8)]( "Cool");

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [June 20, 2005, 11:25am UTC](https://forum.servoy.com/t/convert-fri-may-27-1211-cest-2005/4389/2 "2005-06-20T11:25:54Z")

</div>

Are you sure that this

```auto
Fri May 27 12:43:11 CEST 2005

```

is a “text information”? It looks very much like a date already…

Where does that “text” come from?[/code]

---

<div class="post-metadata">

**Author:** ![r.schneider](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@r.schneider](https://forum.servoy.com/u/r.schneider)\
**Post date:** [June 20, 2005, 11:31am UTC](https://forum.servoy.com/t/convert-fri-may-27-1211-cest-2005/4389/3 "2005-06-20T11:31:34Z")

</div>

This comes from pop3 account  
It is a date, which i try to store in a date field.

I get it with nachricht.getSentDate()

I could not put it into date field directly

I have to store it in a text field and convert afterwards.

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [June 20, 2005, 11:35am UTC](https://forum.servoy.com/t/convert-fri-may-27-1211-cest-2005/4389/4 "2005-06-20T11:35:49Z")

</div>

I would expect a function called “getSentDate” to deliver a date and not text. What happens if you do a typeOf of the result you are getting? What is the exact field type of the date field you tried to insert this value?

---

<div class="post-metadata">

**Author:** ![r.schneider](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@r.schneider](https://forum.servoy.com/u/r.schneider)\
**Post date:** [June 20, 2005, 12:33pm UTC](https://forum.servoy.com/t/convert-fri-may-27-1211-cest-2005/4389/5 "2005-06-20T12:33:32Z")

</div>

> patrick:  
> I would expect a function called “getSentDate” to deliver a date and not text. What happens if you do a typeOf of the result you are getting? What is the exact field type of the date field you tried to insert this value?

I do also expect to get a Date, but if I try

datefield = nachricht.getSentDate()

my datefield stays emtpy. Only if I try

textfield = nachricht.getSentDate()

seem to work.

Sybase Date Format is “dd-mm-yyyy hh:mm:ss”

I am not familiar with the function typeOf. I did not found it in the helpsystem. How is the syntax?

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [June 20, 2005, 2:33pm UTC](https://forum.servoy.com/t/convert-fri-may-27-1211-cest-2005/4389/6 "2005-06-20T14:33:02Z")

</div>

What happens if you do

```auto
var sentDate = nachricht.getSentDate()
var aDate = new Date(aDate)

```

how does aDate look like?

---

<div class="post-metadata">

**Author:** ![r.schneider](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@r.schneider](https://forum.servoy.com/u/r.schneider)\
**Post date:** [June 20, 2005, 3:13pm UTC](https://forum.servoy.com/t/convert-fri-may-27-1211-cest-2005/4389/7 "2005-06-20T15:13:27Z")

</div>

```auto
var sentDate = nachricht.getSentDate()
myDateField = new Date(sentDate)

```

works!

Many Thanks again to munic!
