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

7 years 1 month 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

7 years 1 month ago

In reply to Hi Pradson, by Kurumi

Thanks a lot MIkko.

Thanks a lot MIkko.

Profile picture for user Kurumi

Kurumi

7 years 1 month 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 8 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

  • Thu, 11/19/2026 - 10:57
    Gurux.DLMS.Python 1.0.204
  • Thu, 11/19/2026 - 10:12
    gurux.dlms.c 9.0.2611.1901
  • Tue, 10/13/2026 - 12:00
    gurux.dlms.java 4.0.97
  • Tue, 09/22/2026 - 14:02
    Gurux.DLMS.Net 9.0.2609.2201
  • Mon, 09/21/2026 - 10:18
    Gurux.DLMS.Net 9.0.2609.2101

New forum topics

  • Landis E650 meter reading over DLMS
  • class_id = 40, version = 2, pushsetup Unparsed data frame
  • GXObisValueItem entries without MaskSize appear to be interpreted as bit flags
  • CheckedListBox incorrectly selects GXObisValueItem Value=0 for non-zero values
  • UIValueType=TextBox is rendered as CheckedListBox when Values are defined
More

Who's new

  • Sayang
  • q80435762@gmail.com
  • ONCAK
  • Berhasil
  • ratirvivege1979
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin