How to specify an absolute date in Datasteam Web Service (DSWS)

I got below code snippet from Quick start sample code:

Date = new DSDate()

{

Kind = DSDateKind.TimeSeries,

Start = "-30D",

End = "-10D",

Frequency = DSDateFrequencyNames.D.ToString()

}

But I want to make a request for a single date.

I found below examples from the link http://product.datastream.com/dswsclient/Docs/AboutNetApi.aspx

// Date (Snapshot) 
// An absolute date 
var date1 = new DSSnapshotDate(DSDateType.Absolute(DateTime.Now));

But I dont have DSSnapshotDate class in my datastream service reference.

Is there any other way by which I can make a single request for (Today-1) date using the 1st example that was mentioned in Quick start sample code ?


Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @prashant.busa

    The examples from this link require the DSWS .NET API library.

    However, the below code uses the DSWS SOAP Web Services.

    Date = new DSDate()
    {
    Kind = DSDateKind.TimeSeries,
    Start = "-30D",
    End = "-10D",
    Frequency = DSDateFrequencyNames.D.ToString()
    }

    Refer to this page, the dates can be relative dates or absolute dates or string literals, such as -30D (or) 2011-12-31 (or) BDATE.

    image

    You can use absolute dates with the following code.

    Date = new DSDate()
    {
        Kind = DSDateKind.TimeSeries,                     
        Start = "2019-11-15",
        End = "2019-11-28",
        Frequency = DSDateFrequencyNames.D.ToString()
    }

    Otherwise, you can use a relative date, such as "0D", or "-1D" for the last day.

     Date = new DSDate()
     {
         Kind = DSDateKind.TimeSeries,                     
         Start = "0D",   
         Frequency = DSDateFrequencyNames.D.ToString()
     }



Answers

  • Thank you jirapongse

    I modified your solution a bit and got it working for me

    Date = new DSDate()

    {

    Kind = DSDateKind.Snapshot,

    Start = "2019-11-28",

    End = "2019-11-28",

    Frequency = DSDateFrequencyNames.D.ToString()

    }