Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. The Method CGXDateTime::GetDifference() Is Not Working?

The method CGXDateTime::GetDifference() is not working?

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By pradson , 3 October, 2019
Forums
Gurux.DLMS

Hi Mikko,

I am calculating the difference between two CGXDateTime objects. But I am getting 0 as a return value.
Kindly refer the below mentioned code:
//------------------------------------------------
CGXDateTime start = CGXDateTime::Now();
start1.AddHours(-2);

CGXDateTime end = CGXDateTime::Now();

long diff = CGXDateTime::GetDifference(end.GetValue(), start);
//---------------------------------------------------
Output: diff is 0.
//---------------------------------------------------

Kindly suggest me what should I do.

Thanks & Regards,
Pradson

Profile picture for user Kurumi

Kurumi

6 years 8 months ago

Hi Pradson,

Hi Pradson,

I tested this and there is an error. I made an issue about this.

https://www.gurux.fi/node/13873

This is fixed and a new version is released today.

BR,

Mikko

pradson

6 years 8 months ago

In reply to Hi Pradson, by Kurumi

Thanks a lot MIkko.

Thanks a lot MIkko.

Profile picture for user Kurumi

Kurumi

6 years 8 months ago

Hi Pradson,

Hi Pradson,

I just received info that a new version is released where this is fixed.

BR,
Mikko

Profile picture for user Dmitry

Dmitry

2 years 3 months ago

Hi Mikko! I try this:…

Hi Mikko!
I try this:

QDateTime d1(QDate(2024, 2, 27), QTime(12, 0, 0));
QDateTime d2(QDate(2024, 2, 27), QTime(11, 0, 0));

CGXDateTime gxd1(2024, 2, 27, 11, 0, 0, 0); //February 2024, 27
CGXDateTime gxd2(2024, 2, 27, 12, 0, 0, 0); //February 2024, 27

auto diff1_q = d2.msecsTo(d1); //3600000 - ok
auto diff1_gx = CGXDateTime::GetDifference(gxd1.GetValue(), gxd2); //3600000 - ok

QDateTime d12(QDate(2024, 2, 27), QTime(12, 0, 0));
QDateTime d22(QDate(2023, 12, 27), QTime(11, 0, 0)); //december 2023

CGXDateTime gxd12(2024, 2, 27, 11, 0, 0, 0); //February 2024, 27
CGXDateTime gxd22(2023, 12, 27, 12, 0, 0, 0); //december 2023, 27

auto diff2_q = d12.msecsTo(d22); //-5360400000
auto diff2_gx = CGXDateTime::GetDifference(gxd12.GetValue(), gxd22); //26269200000 - not same value

Also it would be good to add overloaded method static long GetDifference(CGXDateTime& start, CGXDateTime& to);

Thanks!

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin