Convert Date pb

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Franck

    Convert Date pb

    Hi,
    'm gettin mad about date conversion.


    Here is the point.
    Got and add-in for Excel which call functions from a web service (on a
    remote server)


    The remote server has regional settings set to "en-UK" and date to
    dd/MM/yyyy. (I'can't change it !)


    One of my function get a string as parameter and convert it to date in
    the following format yyyy-mm-dd.


    So, Having regional settings set to "fr-ch" (date format dd.mm.yyyy), I

    call my function with "31/10/2003"... Works grate (with every date).


    Changing regional settings to "en-US" and date to default "M/d/yyyy",
    the function do not recognize the date.


    I tried to set CurrentThread culture to a specific one, I tried
    Date.Parse... I must miss somethin...


    Is there a way to get back client date format during request and
    convert the string date he filled to yyyy-mm-dd regarding this format ?



    Help Please !

  • Mythran

    #2
    Re: Convert Date pb


    "Franck" <wesley.saris@g mail.com> wrote in message
    news:1114181792 .116599.143540@ g14g2000cwa.goo glegroups.com.. .[color=blue]
    > Hi,
    > 'm gettin mad about date conversion.
    >
    >
    > Here is the point.
    > Got and add-in for Excel which call functions from a web service (on a
    > remote server)
    >
    >
    > The remote server has regional settings set to "en-UK" and date to
    > dd/MM/yyyy. (I'can't change it !)
    >
    >
    > One of my function get a string as parameter and convert it to date in
    > the following format yyyy-mm-dd.
    >
    >
    > So, Having regional settings set to "fr-ch" (date format dd.mm.yyyy), I
    >
    > call my function with "31/10/2003"... Works grate (with every date).
    >
    >
    > Changing regional settings to "en-US" and date to default "M/d/yyyy",
    > the function do not recognize the date.
    >
    >
    > I tried to set CurrentThread culture to a specific one, I tried
    > Date.Parse... I must miss somethin...
    >
    >
    > Is there a way to get back client date format during request and
    > convert the string date he filled to yyyy-mm-dd regarding this format ?
    >
    >
    >
    > Help Please !
    >[/color]

    Given a date, you can try DateTime.Parse to return a date...

    Let us know how it goes! :)

    Mythran

    Comment

    • Franck

      #3
      Re: Convert Date pb

      The point is that I can figure out how the user filled the date...
      All case worked with a Convert.ToDateT ime.

      31/12/2005 -> OK
      31/12/05 -> OK
      12/31/2005 -> OK
      12/31/05 -> OK


      BUT, when the user send an "ambiguous" date (5/1/2005 could be 5th of
      Jan or 1st of May regarding regional date settings) here is
      nightmare... If the user is in M/d/yyyy, the Convert.ToDateT ime
      convert in dd/MM/yyyy

      SO, I'm trying to know user's date regional settings in order to make
      the correct Date.Parse.

      Help :(



      "Mythran" <kip_potter@hot mail.comREMOVET RAIL> wrote in message news:<eJNM#E1RF HA.204@TK2MSFTN GP15.phx.gbl>.. .[color=blue]
      > "Franck" <wesley.saris@g mail.com> wrote in message
      > news:1114181792 .116599.143540@ g14g2000cwa.goo glegroups.com.. .[color=green]
      > > Hi,
      > > 'm gettin mad about date conversion.
      > >
      > >
      > > Here is the point.
      > > Got and add-in for Excel which call functions from a web service (on a
      > > remote server)
      > >
      > >
      > > The remote server has regional settings set to "en-UK" and date to
      > > dd/MM/yyyy. (I'can't change it !)
      > >
      > >
      > > One of my function get a string as parameter and convert it to date in
      > > the following format yyyy-mm-dd.
      > >
      > >
      > > So, Having regional settings set to "fr-ch" (date format dd.mm.yyyy), I
      > >
      > > call my function with "31/10/2003"... Works grate (with every date).
      > >
      > >
      > > Changing regional settings to "en-US" and date to default "M/d/yyyy",
      > > the function do not recognize the date.
      > >
      > >
      > > I tried to set CurrentThread culture to a specific one, I tried
      > > Date.Parse... I must miss somethin...
      > >
      > >
      > > Is there a way to get back client date format during request and
      > > convert the string date he filled to yyyy-mm-dd regarding this format ?
      > >
      > >
      > >
      > > Help Please !
      > >[/color]
      >
      > Given a date, you can try DateTime.Parse to return a date...
      >
      > Let us know how it goes! :)
      >
      > Mythran[/color]

      Comment

      Working...